home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19970929-19971216 / 000217_news@newsmaster….columbia.edu _Fri Oct 31 10:22:43 1997.msg < prev    next >
Internet Message Format  |  2020-01-01  |  8KB

  1. Return-Path: <news@newsmaster.cc.columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.35.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id KAA25426
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Fri, 31 Oct 1997 10:22:43 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id KAA13623
  7.     for kermit.misc@watsun; Fri, 31 Oct 1997 10:22:42 -0500 (EST)
  8. Path: news.columbia.edu!watsun.cc.columbia.edu!fdc
  9. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  10. Newsgroups: comp.protocols.kermit.misc
  11. Subject: Re: Need help with Kermit script
  12. Date: 31 Oct 1997 15:22:40 GMT
  13. Organization: Columbia University
  14. Lines: 152
  15. Message-ID: <63ct40$kht$1@apakabar.cc.columbia.edu>
  16. References: <3458A6ED.F555C0D0@alliedsignal.com>
  17. NNTP-Posting-Host: watsun.cc.columbia.edu
  18. Xref: news.columbia.edu comp.protocols.kermit.misc:7999
  19.  
  20. In article <3458A6ED.F555C0D0@alliedsignal.com>,
  21. John M. Ritter <jmr@snowhite.mto.allied.com> wrote:
  22. : I am trying, for the first time, to write a script that logs onto a
  23. : service and captures data to a file using C-Kermit 6.0.192, 6 Sep 96,
  24. : for UnixWare 2. There are a few things that are confusing me, and I'd
  25. : appreciate some pointers.
  26. : 1. Since this will run on different systems in different directories,
  27. :    via cron, a shell script kicks off the session with:
  28. :      kermit -E -H -l /dev/term/a08m -b 38400 -m usrobotics -y ./.kermitrc   
  29. :    The problem is, if the first command is DIAL phone-number, kermit
  30. :    complains: Sorry, you must SET MODEM first
  31. :    Huh? if I SHOW MODEM, everything is OK. Why can't I jump right in
  32. :    to a dial command? Of course, if I manually SET MODEM, then it
  33. :    complains Sorry, you must SET LINE first (and ditto for SPEED).
  34. The initialization file is executed before the command-line options (page
  35. 462, "Using C-Kermit", 2nd Ed.).  So you should not be using your
  36. initialization file as an application-specific script.  Call it something
  37. else, like "xx.ksc" and then:
  38.  
  39.   kermit xx.ksc -E -H -l /dev/term/a08m -b 38400 -m usrobotics
  40.  
  41. : 2. This service is accessed via SprintNet. After connecting to the
  42. :    service, I get trampled with escape codes to clear the screen, change
  43. :    text colors and dozens of backspaces. The login prompt looks like:
  44. :
  45. :    999999 CONNECTED^M
  46. :        ^[[2J^H^H^H^H  ^[[6n^[[5n^[[0c^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H
  47. : ^H^H^H^H^H^H^H^H^H^H^H^H^H                             ^[[12h^H^H^H^H^H
  48. : ^H^H^H^H^H^H^H
  49. :                     ^[[32m^H^H^H^H^H^H^H^H        ^M
  50. :    ^M
  51. :    311061100020 14400:8T 128x2,PTRA W002-R5020200#0012 CONNECTED^M
  52. :         ^[[31m^H^H^H^H^H     ^M
  53. :    WE AUTHORIZE USE OF THIS SERVICE ONLY THROUGH EXPRESS WRITTEN PERMISSION.
  54. :   ^MUNAUTHORIZED ACCESS OR USE IS A VIOLATION OF LAW.     ^[[37m^H^H^H^H^H  
  55. :   ^M
  56. :    ENTER COMPANY ID?^MENTER COMPANY ID? (company id gets entered here)
  57. :    ENTER USER ID?BBBBBBBBBBBBBBBBB^MENTER USER ID?XXXXXXXXXXXXXXXXX^MENTER
  58. : USER
  59. : ID?^MENTER USER ID? (user id gets entered here)
  60. :    Using the examples from the book (See? I bought the book!! Both
  61. :    editions too!) and a plain INPUT, I never seem to find the prompt.
  62. :
  63. What does your INPUT statement look like?
  64.  
  65. :    What seems to work fairly well is clearing the buffer and performing
  66. :    a \Frindex on \v(input), but the escape codes *still* end up getting
  67. :    back to either the kermit command prompt or a UNIX prompt.
  68. To explain this, I would need to see your script, but read on...
  69.  
  70. :    There must be a simpler way to scan for this pattern!
  71. I'll try to explain.  The script language is designed to handle a sequential
  72. stream of input, like when you are logging in to UNIX.  It does not (yet)
  73. incorporate any form of ex-post-facto screen scraping (HLLAPI-style
  74. scripting), in which fragments may be painted in any order, which is
  75. impossible in any case in a Kermit version that does not incorporate a
  76. terminal emulator (thus, we might be able to add screen-scraping functions 
  77. to K95, but not to UNIX C-Kermit).
  78.  
  79. But that does not mean you can't use it to handle formatted screens; it just
  80. takes a bit of ingenuity.  The trick is to analyze the input to see if there
  81. is anything you can identify that indicates that it has stopped sending you
  82. stuff, as in the IBM Mainframe fullscreen login example on pp.438-439.  In
  83. this case we have to wait until the mainframe says "READY", and then we can
  84. send our stuff.
  85.  
  86. I can't tell from your transcript above whether "ENTER USER ID?" is the last
  87. thing that SprintNet sends before you are to send your login string.  In any
  88. case I can see that it sends this prompt more than once.  So it is very
  89. likely that Sprintnet is NOT ready for you to send your user ID until after
  90. it sends the LAST COPY of this prompt -- if indeed the prompt is the last
  91. thing it sends.
  92.  
  93. So the exact form your script takes, again, depends on exactly what
  94. SprintNet is sending.  If it sends "ENTER USER ID?" three times and then
  95. waits, then you need four INPUT commands for that string (in series or in
  96. a loop).  Sometimes a PAUSE is needed before you send your response, to give
  97. the host sufficient time to turn the direction of transmission around.
  98.  
  99. Based purely on the transcript above, and just guessing at the timings
  100. involved, I'd suggest something like this:
  101.  
  102.     input 30 ENTER COMPANY ID?  ; Wait for first COMPANY ID prompt
  103.     if fail (do something)
  104.     input 5 ENTER COMPANY ID?   ; Now get the second one
  105.     if fail (do something)
  106.     pause 1                     ; Wait a sec
  107.     output (company ID)\13      ; Now send the company ID
  108.         
  109. And then something similar with the USER ID prompt.
  110.  
  111. Another approach is suggested on page 426 -- the SET INPUT SILENCE command.
  112. This lets you tell Kermit to wait until the host stops transmitting.  This
  113. way you don't have to depend on or hardwire the exact number of repeated
  114. prompts into your script.
  115.  
  116.     input 30 ENTER COMPANY ID?  ; Wait for first COMPANY ID prompt.
  117.     if fail (do something)
  118.     set input silence 10        ; Wait for 10 seconds of silence.
  119.     while success { input 1 }   ; Gobble stuff up.
  120.     ; Get here after 10 seconds of silence
  121.     output (company ID)\13      ; Now send the company ID.
  122.     set input silence 0         ; Remove the silence criterion.
  123.  
  124. Experiment with these techniques and see if you have better luck.
  125.  
  126. : 3. The section "Downloading to C-Kermit" has an example of grabbing a
  127. :    lasagna recipe, but only gives a hint on automating it. I tried to
  128. :    get back to a kermit prompt from a script using OUTPUT \v(escape)C
  129. :    (Why isn't this listed in the table of built-in variables??)
  130. :
  131. Because it isn't a built-in variable.
  132.  
  133. :    ... and do the log session, but when all is done, the session log file
  134. :    is zero bytes.
  135. We try to explain this in the documentation (e.g. see pages 419-420).  When a
  136. script is running, the CONNECT command is NOT running.  There is no escaping
  137. back in a script.  Kermit is *already* at its "command prompt".
  138.  
  139. :    Does anybody have an example of this that actually works?
  140. When capturing files without Kermit protocol in a script you need to specify
  141. the completion criterion, and it better be something that does not appear in
  142. the file itself.  Let's say your host prompt is dollar sign followed by space
  143. on the left margin, i.e. preceded by CR and LF, and the host command to
  144. display a file is "type", and the filename is (what else) oofa.txt.
  145.  
  146.   output type oofa.txt     ; Send the command but no carriage return.
  147.   clear device             ; So its echo doesn't go in the log.
  148.   log session oofa.log     ; Start the log.
  149.   output \13               ; Now send the carriage return.
  150.   input 300 {\13\10$ }     ; And wait for the system prompt.
  151.   if fail (do something)
  152.   close session            ; Close the session log.
  153.  
  154. That should do it, provided the file does not contain CR LF $ SP.  If it
  155. does -- well, Kermit has no way of knowing whether this sequence comes from
  156. the file or is the system prompt.  If you wanted to allow for that case,
  157. the script becomes slightly more involved (use INPUT in a loop to search
  158. for CRLF, write each line to a WRITE FILE, and SET INPUT SILENCE as your
  159. completion criterion).
  160.  
  161. Does this help?
  162.  
  163. - Frank